package com.naiterui.ehp.bs.doctor.repository;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bp.domain.DrFollowUpRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * 随访任务
 *
 * @author yangfuya
 * @since 2022/1/5
 */
@Repository
public interface IDrFollowUpRecordRepository extends BaseJpaRepository<DrFollowUpRecord, Long> {

    /**
     * 分页获取随访列表
     *
     * @param doctorId
     * @param status
     * @param inquirerName
     * @param pageable
     * @return
     */
    Page<DrFollowUpRecord> findByDoctorIdAndStatusAndInquirerNameLike(Long doctorId, Integer status,
                                                                      String inquirerName, Pageable pageable);

    /**
     * 分页获取随访列表
     *
     * @param doctorId
     * @param status
     * @param pageable
     * @return
     */
    Page<DrFollowUpRecord> findByDoctorIdAndStatus(Long doctorId, Integer status, Pageable pageable);

    /**
     * 随访
     *
     * @param id
     * @return
     */
    DrFollowUpRecord findFirstById(Long id);

    List<DrFollowUpRecord> findAllByFollowNo(String followNo);

    /**
     * 查询医生某天的问诊计划
     *
     * @param date
     * @param pageable
     * @return
     */
    Page<DrFollowUpRecord> findByDoctorIdAndBeginTime(Long doctorId, Date date, Pageable pageable);


    /**
     * 查询医生随访日历页月份数据
     *
     * @param doctorId
     * @param startTime
     * @param endTime
     * @return
     */
    List<DrFollowUpRecord> findByDoctorIdAndBeginTimeBetween(Long doctorId, Date startTime, Date endTime);

    List<DrFollowUpRecord> findByDoctorIdAndPatientIdAndTypeAndStatusNotAndBeginTimeIn(Long doctorId, Long patientId, Integer type, Integer status, List<Date> collectDate);

    List<DrFollowUpRecord> findByDoctorIdAndPatientIdAndBeginTimeAndType(Long doctorId, Long patientId, Date date, int type);
}
